﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace DataObject.Adv
{
    public class AdvDAL
    {
        /***************************************
        = Back End
        -------------------------------------- */
        public static void Adv_Create(AdvObject o)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Adv_Create", o.TypeId, o.Priority, o.ImagePath, o.Url);
        }

        public static void Adv_Update_Url(int advId, string url)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Adv_Update_Url", advId, url);
        }

        public static void Adv_Delete(int advId)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Adv_Delete", advId);
        }

        public static void Adv_DeleteByType(int typeId)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Adv_DeleteByType", typeId);
        }

        public static IDataReader Adv_GetById(int advId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Adv_GetById", advId);
        }

        /***************************************
        = Front End
        -------------------------------------- */
        public static IDataReader Adv_GetListByTypeId(int typeId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Adv_GetListByTypeId", typeId);
        }
    }
}
